package com.qf.web.controller;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.lang.reflect.Method;

/**
 * projectName:day15_myxiaomi
 * author:lcy
 * time:2023/11/29 11:12
 * description:
 */
@WebServlet("/testservlet")
public class TestServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String methodName = request.getParameter("method");
        try {
            Method method= this.getClass().getMethod(methodName,HttpServletRequest.class,HttpServletResponse.class);
            if(method!=null){
                method.invoke(this,request,response);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
    protected void tt(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("测试成功......");
    }
}


